package knihaprichodu.frm;

import java.awt.Choice;
import java.awt.Label;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * @author balat
 */
class ZapisDatumuACasu implements ItemListener {

    private final Choice choice;
    private final Label label;
    private final String string;

    public ZapisDatumuACasu(String string, Choice choice, Label label) {
        this.choice = choice;
        this.label = label;
        this.string = string;
    }

    @Override
    public void itemStateChanged(ItemEvent e) {
        String detail = choice.getSelectedItem();
        String format = String.format("{0} {1}", string, detail);
        label.setText(format);
    }
}
